<template>
  <el-table
    :data="tableData"
    @row-click="handleRowClick"
    style="width: 100%;"
    max-height="308"

  >
    <el-table-column
      prop="autoTypeName"
      label="车辆类型"
      fixed
      width="90"
      align="center"
      show-overflow-tooltip
    >
    </el-table-column>
    <el-table-column prop="plate" label="车牌"  align="center" show-overflow-tooltip>
    </el-table-column>
    <el-table-column prop="lane" label="车道"  align="center" show-overflow-tooltip>
    </el-table-column>
    <el-table-column
      prop="autoWeight"
      label="总重(kg)"
      width="90"
      align="center"
      show-overflow-tooltip
    >
    </el-table-column>
    <el-table-column prop="axisNum" label="轴数" align="center" show-overflow-tooltip>
    </el-table-column>
    <el-table-column
      prop="autoSpeed"
      label="速度(km/h)"

      align="center"
      show-overflow-tooltip
    >
    </el-table-column>
    <el-table-column prop="passingDate" label="过车时间" width="150" align="center" show-overflow-tooltip>
    <template slot-scope="scope">
        <span>{{ parseTime(scope.row.passingDate)}}</span>
      </template>
    </el-table-column>
    <el-table-column
      prop="axisWeight1"
      label="轴重1(kg)"

      align="center"
      show-overflow-tooltip
    >
    </el-table-column>
    <el-table-column
      prop="axisWeight2"
      label="轴重2(kg)"

      align="center"
      show-overflow-tooltip
    >
    </el-table-column>
    <el-table-column
      prop="axisWeight3"
      label="轴重3(kg)"

      align="center"
      show-overflow-tooltip
    >
    </el-table-column>
    <el-table-column
      prop="axisWeight4"
      label="轴重4(kg)"

      align="center"
      show-overflow-tooltip
    >
    </el-table-column>
    <el-table-column
      prop="axisWeight5"
      label="轴重5(kg)"

      align="center"
      show-overflow-tooltip
    >
    </el-table-column>
    <el-table-column
      prop="axisWeight6"
      label="轴重6(kg)"

      align="center"
      show-overflow-tooltip
    >
    </el-table-column>
    <el-table-column
      prop="axisWeight7"
      label="轴重7(kg)"

      align="center"
      show-overflow-tooltip
    >
    </el-table-column>
    <!-- <el-table-column
      prop="overLimit"
      label="超限量(t)"

      align="center"
    >
    </el-table-column> -->
    <!-- <el-table-column prop="overRun" label="超限(%)" align="center">
    </el-table-column> -->
  </el-table>
</template>

<script>
  import moment from 'moment'
export default {
  props:{
    tableData: {
      type: Array
    },
  },
  // watch: {
  //   tableData: {
  //     handler(val, old) {
  //       // console.log(val,'33333333333333333')
  //       // val.forEach(item=>{
  //       //   item.passingDate = moment(item.passingDate).format('YYYY-MM-DD HH:mm:ss')
  //       // })
  //     },
  //     immediate: true,
  //     deep:true
  //   }
  // },
  data () {
    return {
      // tableData: [{
      //   carType: '大型车',
      //   carPlate: '苏A345678',
      //   carLane: '1',
      //   totalWeight: '1.37',
      //   axesNum: '2',
      //   carSpeed: '48',
      //   cartime: '2020-03-23 16:00',
      //   oneWeight: '轴重1(t)',
      //   twoWeight: '轴重1(t)',
      //   threeWeight: '轴重1(t)',
      //   fourWeight: '轴重1(t)',
      //   fiveWeight: '轴重1(t)',
      //   sixWeight: '轴重1(t)',
      //   sevenWeight: '轴重1(t)',
      //   overLimit: '--',
      //   overRun: '--'
      // }, {
      //   carType: '大型车',
      //   carPlate: '苏A345678',
      //   carLane: '1',
      //   totalWeight: '1.37',
      //   axesNum: '2',
      //   carSpeed: '48',
      //   cartime: '2020-03-23 16:00',
      //   oneWeight: '轴重1(t)',
      //   twoWeight: '轴重1(t)',
      //   threeWeight: '轴重1(t)',
      //   fourWeight: '轴重1(t)',
      //   fiveWeight: '轴重1(t)',
      //   sixWeight: '轴重1(t)',
      //   sevenWeight: '轴重1(t)',
      //   overLimit: '--',
      //   overRun: '--'
      // }, {
      //   carType: '大型车',
      //   carPlate: '苏A345678',
      //   carLane: '1',
      //   totalWeight: '1.37',
      //   axesNum: '2',
      //   carSpeed: '48',
      //   cartime: '2020-03-23 16:00',
      //   oneWeight: '轴重1(t)',
      //   twoWeight: '轴重1(t)',
      //   threeWeight: '轴重1(t)',
      //   fourWeight: '轴重1(t)',
      //   fiveWeight: '轴重1(t)',
      //   sixWeight: '轴重1(t)',
      //   sevenWeight: '轴重1(t)',
      //   overLimit: '--',
      //   overRun: '--'
      // }, {
      //   carType: '大型车',
      //   carPlate: '苏A345678',
      //   carLane: '1',
      //   totalWeight: '1.37',
      //   axesNum: '2',
      //   carSpeed: '48',
      //   cartime: '2020-03-23 16:00',
      //   oneWeight: '轴重1(t)',
      //   twoWeight: '轴重1(t)',
      //   threeWeight: '轴重1(t)',
      //   fourWeight: '轴重1(t)',
      //   fiveWeight: '轴重1(t)',
      //   sixWeight: '轴重1(t)',
      //   sevenWeight: '轴重1(t)',
      //   overLimit: '--',
      //   overRun: '--'
      // }, {
      //   carType: '大型车',
      //   carPlate: '苏A345678',
      //   carLane: '1',
      //   totalWeight: '1.37',
      //   axesNum: '2',
      //   carSpeed: '48',
      //   cartime: '2020-03-23 16:00',
      //   oneWeight: '轴重1(t)',
      //   twoWeight: '轴重1(t)',
      //   threeWeight: '轴重1(t)',
      //   fourWeight: '轴重1(t)',
      //   fiveWeight: '轴重1(t)',
      //   sixWeight: '轴重1(t)',
      //   sevenWeight: '轴重1(t)',
      //   overLimit: '--',
      //   overRun: '--'
      // }, {
      //   carType: '大型车',
      //   carPlate: '苏A345678',
      //   carLane: '1',
      //   totalWeight: '1.37',
      //   axesNum: '2',
      //   carSpeed: '48',
      //   cartime: '2020-03-23 16:00',
      //   oneWeight: '轴重1(t)',
      //   twoWeight: '轴重1(t)',
      //   threeWeight: '轴重1(t)',
      //   fourWeight: '轴重1(t)',
      //   fiveWeight: '轴重1(t)',
      //   sixWeight: '轴重1(t)',
      //   sevenWeight: '轴重1(t)',
      //   overLimit: '--',
      //   overRun: '--'
      // }, {
      //   carType: '大型车',
      //   carPlate: '苏A345678',
      //   carLane: '1',
      //   totalWeight: '1.37',
      //   axesNum: '2',
      //   carSpeed: '48',
      //   cartime: '2020-03-23 16:00',
      //   oneWeight: '轴重1(t)',
      //   twoWeight: '轴重1(t)',
      //   threeWeight: '轴重1(t)',
      //   fourWeight: '轴重1(t)',
      //   fiveWeight: '轴重1(t)',
      //   sixWeight: '轴重1(t)',
      //   sevenWeight: '轴重1(t)',
      //   overLimit: '--',
      //   overRun: '--'
      // }]

    };
  },
  components: {},
  methods: {
    handleRowClick (row, event, column) {
      // 时间戳转换！！！！
      let datatow = row
      datatow.passingDate = this.parseTime(datatow.passingDate)
      this.$emit("handleIsShowDetail", datatow);
    },
    parseTime(timestamp) {
      var date = new Date(timestamp); //时间戳为10位需*1000，时间戳为13位的话不需乘1000
      var Y = date.getFullYear() + "-";
      var M =
        (date.getMonth() + 1 < 10
          ? "0" + (date.getMonth() + 1)
          : date.getMonth() + 1) + "-";
      var D =
        (date.getDate() < 10 ? "0" + date.getDate() : date.getDate()) + " ";
      var h =
        (date.getHours() < 10 ? "0" + date.getHours() : date.getHours()) + ":";
      var m =
        (date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes()) +
        ":";
      var s =
        date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();

      let strDate = Y + M + D + h + m + s;
      console.log(strDate); //2020-05-08 17:44:56
      return strDate;
    },
  }
};
</script>

<style lang="scss" scoped>
/deep/.el-table {
  border: 1px solid #ebeef5;
  border-bottom: 0;
}
</style>
